package com.caikun.service_management.service.impl;

import com.caikun.model.entity.ServiceEntity;
import com.caikun.model.vo.PackageVO;
import com.caikun.service_management.mapper.ServiceMapper;
import com.caikun.service_management.service.ServiceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ServiceServiceImpl implements ServiceService {
    @Autowired
    private ServiceMapper serviceMapper;

    @Override
    public List<ServiceEntity> listServices(String serviceName) {
        return serviceMapper.selectByNameLike(serviceName);
    }

    @Override
    public ServiceEntity addService(ServiceEntity serviceEntity) {
        serviceMapper.insert(serviceEntity);

        return serviceEntity;
    }

    @Override
    public Boolean updateService(ServiceEntity serviceEntity) {
        Boolean res = serviceMapper.updateById(serviceEntity);
        return res;
    }

    @Override
    public Boolean deleteService(Integer serviceId) {
        Boolean res = serviceMapper.deleteById(serviceId);
        return res;
    }

    @Override
    public List<ServiceEntity> queryAllService() {
        List<ServiceEntity> serviceEntities = serviceMapper.queryAllService();
        return serviceEntities;
    }

    @Override
    public List<PackageVO> queryAllPackageWithServices() {
        List<PackageVO> packageVOList = serviceMapper.queryAllPackageWithService();
        return packageVOList;
    }
} 